<template>
	<view>
		<view class="top-box">
			<image class="top-bg" style="width: 695rpx;height: 262rpx;" :src="imgUrl + 'wallet-bg.png'"></image>
			<view class="top-text-box">
				<view style="margin-left: 30rpx;margin-top: 37rpx;font-size: 30rpx;color: white;">
					总资产：
				</view>
				<view class="top-text-box-but">
					<view style="transform: translateY(-20rpx);">
						我的金额：
					</view>
					<view>
						<text>￥</text>
						<text style="font-size: 90rpx;">{{int}}</text>
						<text style="font-size: 30rpx;">.{{float}}</text>
					</view>
				</view>
				
			</view>
		</view>
		<view style="padding-top: 50rpx;padding-left: 33rpx;font-size: 36rpx;color: #323232;font-weight: 600;">
			现金明细
		</view>
		<view style="margin-top: 30rpx;padding-bottom: 150rpx;" class="cont-box">
			<view v-if="mingxiArr.length > 0">
				<view v-for="(it,i) in mingxiArr" :key="i">
					<view class="title">
						{{it.months}}
					</view>
					<view class="cont-list" v-for="(item,index) in it.day" :key="index">
						<view>
							<view style="color: #323232;font-size: 30rpx;">
								{{item.title}}
							</view>
							<view style="font-size: 26rpx;padding-top: 20rpx;color: #A7A7A7;">
								{{item.create_at}}
							</view>
						</view>
						<view style="font-size: 40rpx;color: #323232;font-weight: 600;">
							{{item.money}}
						</view>
					</view>
				</view>
				<view class="finished">—— 没有更多了 ——</view>
			</view>
			
			<view class="zanwu-data" v-else>暂无数据</view>
		</view>
		
		
		
		<view @click="chongzhi" class="but">
			充值
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				imgUrl: 'https://syxiyi.oss-cn-shenzhen.aliyuncs.com/frontend/img/',
				walletMoney:'100.10',
				int:0,
				float:0,
				arr:[],
				userinfo: '',
				mingxiArr: [],
				store_id: ''
			}
		},
		onLoad() {
			this.store_id = uni.getStorageSync('store_id')
		},
		onShow() {
			let loginstatus = uni.getStorageSync('token');
			if(loginstatus)
			{
				this.getMingxi()
				this.getUserInfo()
			}
			
		},
		methods:{
			chongzhi(){
				uni.navigateTo({
					url:'chongzhi/index'
				})
			},
			getUserInfo() {
				this.$ajaxRequest.get(this.baseUrl + 'user/info', {
					store_id: this.store_id
				}, true).then(res => {
					console.log(res)
					if (res.data.code == 200) {
						// this.userinfo = res.data.data
						let moneyarr = res.data.data.money.split('.')
						this.int = moneyarr[0]
						this.float = moneyarr[1]
					} else {
						uni.showToast({
							title:res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			getMingxi() {
				this.$ajaxRequest.get(this.baseUrl + 'shop/member/record', {}, true).then(res => {
					if (res.data.code == 200) {
						this.mingxiArr = res.data.data
						console.log(this.mingxiArr)
					} else {
						uni.showToast({
							title:res.data.msg,
							icon:'none'
						})
					}
				})
			}
		}
	}
</script>

<style>
	.but {
		position: fixed;
		bottom: 30rpx;
		width: 690rpx;
		left: 30rpx;
		padding: 20rpx 0rpx 20rpx 0rpx;
		text-align: center;
		font-size: 30rpx;
		background: linear-gradient(-17deg, rgba(255, 114, 59, 1), rgba(255, 147, 67, 1));
		color: white;
		border-radius: 40rpx;
	}
	.cont-list{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding:  20rpx;
		border-bottom: 1rpx solid rgba(167,167,167,.2);
	}
	.title{
		padding: 10rpx 30rpx 10rpx 30rpx;
		color: #323232;
		font-size: 30rpx;
		background-color: #F5F5F5;
		font-weight: 600;
	}
	.top-box{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		position: relative;
		margin-top: 30rpx;
	}
	.top-bg{
		top: 0rpx;
		position: absolute;
	}
	.top-text-box{
		width: 695rpx;
		position: relative;
		z-index: 10;
	}
	.top-text-box-but{
		display: flex;
		align-items: flex-end;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 30rpx;
		color: white;
		margin-top: 20rpx;
	}
</style>
